<?php

namespace App\Kuafu\Shop\Service;

use App\Kuafu\Audit\Enum\AuditEventCodeEnum;
use App\Kuafu\Base\Service\BaseService;
use App\Kuafu\Common\Service\CommonService;
use App\Kuafu\Pay\Model\PayStreamModel;
use App\Kuafu\Pay\Model\ShopPaymentModel;
use App\Kuafu\Shop\Enum\ShopCacheEnum;
use App\Kuafu\Shop\Enum\ShopCodeEnum;
use App\Kuafu\Shop\Exceptions\ShopException;
use App\Kuafu\Shop\Model\Shop;
use App\Kuafu\Shop\Model\ShopPaymentsModel;
use Illuminate\Support\Facades\Cache;
use function Symfony\Component\String\s;

class ShopPaymentService extends BaseService
{

    /**
     * 获取支付配置
     *
     * @return array[]
     */
    public function getFyPayConfig(): array
    {
        $aliPay   = 1; // 阿里云支付
        $wxPay    = 1; // 微信支付
        $unionPay = 0; // 云闪付支付

        $shopPaymentInfo = ShopPaymentModel::query()
                                           ->where('payChannel', PayStreamModel::PAY_CHANNEL_FY)
                                           ->where('shopId', $this->shopId)
                                           ->whereRaw("payConfig -> '$.unionPay' = 1") // 云闪付
                                           ->first();
        if (!empty($shopPaymentInfo)) {
            $unionPay = 1;
        }
        return [
            'aliPay'   => $aliPay,
            'wxPay'    => $wxPay,
            'unionPay' => $unionPay
        ];
    }

    public function getPaymentList()
    {

    }
}
